<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <div>{{words}}</div>
      <button @click="reverse">逆转世界</button>
    </div>
    <script src="../js/vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          words: "Hello,World",
        },
        methods: {
          reverse() {
            let newWords=[]
            for(let char of this.words){
                // console.log('char',char);
                newWords.unshift(char)
            }
            // console.log('newWords',newWords);
            // console.log('newWords',newWords.join(''));
            this.words =  newWords.join('')
          },
        },
      });
    </script>
  </body>
</html>
